﻿using AutoMapper;
using MediatR;
using S.Common.EditReproductivePresenceStateHelper;
using S.Common.EditWanderStateHelper;
using S.PurchaseAndSales.Api.Application.Command.SheepSaleCommand;
using S.PurchaseAndSales.Domain.Model;
using S.PurchaseAndSales.Infrastructure.Interface.SalesForm;

namespace S.PurchaseAndSales.Api.Application.CommandHandlers.SheepSaleHandler
{
    public class SaleSheepUpdateAllCommandHandler : IRequestHandler<SaleSheepUpdateAllCommand, bool>
    {
        private readonly ISheepSaleRepository repository;
        private readonly IMapper mapper;

        public SaleSheepUpdateAllCommandHandler(ISheepSaleRepository repository,IMapper mapper)
        {
            this.repository = repository;
            this.mapper = mapper;
        }
        /// <summary>
        /// 修改羊只销售
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<bool> Handle(SaleSheepUpdateAllCommand request, CancellationToken cancellationToken)
        {
            SheepSaleModel sheepSaleModel = mapper.Map<SheepSaleModel>(request);
           
            return repository.UpdateAsync(sheepSaleModel);
        }
    }
}
